package com.frcdi.qms.web.controller.system;

import com.frcdi.qms.common.annotation.Log;
import com.frcdi.qms.common.core.controller.BaseController;
import com.frcdi.qms.common.core.domain.AjaxResult;
import com.frcdi.qms.common.core.page.TableDataInfo;
import com.frcdi.qms.common.enums.BusinessType;
import com.frcdi.qms.common.utils.poi.ExcelUtil;
import com.frcdi.qms.system.domain.SysUserOperLog;
import com.frcdi.qms.system.service.ISysUserOperLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 操作日志Controller
 *
 * @author cell
 * @date 2023-08-01
 */
@Api(tags = "操作日志")
@RestController
@RequestMapping("/system/log")
public class SysUserOperLogController extends BaseController
{
    @Autowired
    private ISysUserOperLogService sysUserOperLogService;

    /**
     * 查询操作日志列表
     */
    @ApiOperation("查询操作日志列表")
    @PreAuthorize("@ss.hasPermi('system:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysUserOperLog sysUserOperLog)
    {
        startPage();
        List<SysUserOperLog> list = sysUserOperLogService.selectSysUserOperLogList(sysUserOperLog);
        return getDataTable(list);
    }

    /**
     * 导出操作日志列表
     */
    @ApiOperation("导出操作日志列表")
    @PreAuthorize("@ss.hasPermi('system:log:export')")
    @Log(title = "操作日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysUserOperLog sysUserOperLog)
    {
        List<SysUserOperLog> list = sysUserOperLogService.selectSysUserOperLogList(sysUserOperLog);
        ExcelUtil<SysUserOperLog> util = new ExcelUtil<SysUserOperLog>(SysUserOperLog.class);
        util.exportExcel(response, list, "操作日志数据");
    }

    /**
     * 获取操作日志详细信息
     */
    @ApiOperation("获取操作日志详细信息")
    @PreAuthorize("@ss.hasPermi('system:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysUserOperLogService.selectSysUserOperLogById(id));
    }

//    /**
//     * 新增操作日志
//     */
//    @PreAuthorize("@ss.hasPermi('system:log:add')")
//    @Log(title = "操作日志", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody SysUserOperLog sysUserOperLog)
//    {
//        return toAjax(sysUserOperLogService.insertSysUserOperLog(sysUserOperLog));
//    }
//
//    /**
//     * 修改操作日志
//     */
//    @PreAuthorize("@ss.hasPermi('system:log:edit')")
//    @Log(title = "操作日志", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody SysUserOperLog sysUserOperLog)
//    {
//        return toAjax(sysUserOperLogService.updateSysUserOperLog(sysUserOperLog));
//    }
//
//    /**
//     * 删除操作日志
//     */
//    @PreAuthorize("@ss.hasPermi('system:log:remove')")
//    @Log(title = "操作日志", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids)
//    {
//        return toAjax(sysUserOperLogService.deleteSysUserOperLogByIds(ids));
//    }
}

